package gorails.com;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBAdapter extends SQLiteOpenHelper {

    private static final int DATABASE_VERSION = 1;
    //Rail Lines Table
    private static final String TABLE_LINE = "line";
    private static final String LINE_COLUMN = "metra";
    private static final String COLUMN_SIZE = "stationSize";
    //-------End
    
    //Stations Table
    private static final String TABLE_STATION = "station";
    private static final String COLUMN_UPN = "UnionPacificNorth";
	private static final String COLUMN_MDN = "MilwaukeeDistrictNorth";
	private static final String COLUMN_NCS = "NorthCentralService";
	private static final String COLUMN_UPNW = "UnionPacificNorthwest";
	private static final String COLUMN_MDW = "MilwaukeeDistrictWest";
	private static final String COLUMN_UPW = "UnionPacificWest";
	private static final String COLUMN_BNSF = "BNSFRailway";
	private static final String COLUMN_HC = "HeritageCorridor";
	private static final String COLUMN_SWS = "SouthwestService";
	private static final String COLUMN_RID = "RockIslandDistrict";
	private static final String COLUMN_MED = "MetraElectricDistrict";
	//-------End
	
	//------UPN Table
	/*
	 * As reference, these Individual lines are indexed based on: table for outboundWeekday, outboundSat,
	 * outboundSunday, inboundWeekday, inboundSat,inboundSunday
	 * then they are column indexed based on train#
	 * and row indexed based on earilest departure time from station to fartest destination
	 */
	private static final String TABLE_UPN_OW = "UnionPacificNorth_OW";
	private static final String TABLE_UPN_OS = "UnionPacificNorth_OS";
	private static final String TABLE_UPN_OH = "UnionPacificNorth_OH";
	private static final String TABLE_UPN_IW = "UnionPacificNorth_IW";
	private static final String TABLE_UPN_IS = "UnionPacificNorth_IS";
	private static final String TABLE_UPN_IH = "UnionPacificNorth_IH";
    private static int[] UPN_IW_Trains = new int[35];
    private static int[] UPN_OW_Trains = new int[35];
    private static int[] UPN_IS_Trains;
    private static int[] UPN_OS_Trains;
	private static int[] UPN_IH_Trains;
	private static int[] UPN_OH_Trains;
	//--------------END UPN------
	//--------MDN Start-----------
	private static final String TABLE_MDN_OW = "MilwaukeeDistrictNorth_OW";
	private static final String TABLE_MDN_OS = "MilwaukeeDistrictNorth_OS";
	private static final String TABLE_MDN_OH = "MilwaukeeDistrictNorth_OH";
	private static final String TABLE_MDN_IW = "MilwaukeeDistrictNorth_IW";
	private static final String TABLE_MDN_IS = "MilwaukeeDistrictNorth_IS";
	private static final String TABLE_MDN_IH = "MilwaukeeDistrictNorth_IH";
    private static int[] MDN_IW_Trains = new int[33];
    private static int[] MDN_OW_Trains = new int[33];
    private static int[] MDN_IS_Trains = new int[12];
    private static int[] MDN_OS_Trains = new int[12];
	private static int[] MDN_IH_Trains;
	private static int[] MDN_OH_Trains;
	//------ENd MDN-------
	//-----NCS Start------
	private static final String TABLE_NCS_OW = "NorthCentralService_OW";
	private static final String TABLE_NCS_IW = "NorthCentralService_IW";
    private static int[] NCS_IW_Trains = new int[11];
    private static int[] NCS_OW_Trains = new int[11];
	//----NCS End-----
	//----NPNW------
    private static final String TABLE_UPNW_OW = "UnionPacificNorthwest_OW";
	private static final String TABLE_UPNW_OS = "UnionPacificNorthwest_OS";
	private static final String TABLE_UPNW_OH = "UnionPacificNorthwest_OH";
	private static final String TABLE_UPNW_IW = "UnionPacificNorthwest_IW";
	private static final String TABLE_UPNW_IS = "UnionPacificNorthwest_IS";
	private static final String TABLE_UPNW_IH = "UnionPacificNorthwest_IH";
    private static int[] UPNW_IW_Trains = new int[32];
    private static int[] UPNW_OW_Trains = new int[32];
    private static int[] UPNW_IS_Trains;
    private static int[] UPNW_OS_Trains;
	private static int[] UPNW_IH_Trains;
	private static int[] UPNW_OH_Trains;
	//------End NPNW-----
	//------MDW-------
    private static final String TABLE_MDW_OW = "MilwaukeeDistrictWest_OW";
	private static final String TABLE_MDW_OS = "MilwaukeeDistrictWest_OS";
	private static final String TABLE_MDW_OH = "MilwaukeeDistrictWest_OH";
	private static final String TABLE_MDW_IW = "MilwaukeeDistrictWest_IW";
	private static final String TABLE_MDW_IS = "MilwaukeeDistrictWest_IS";
	private static final String TABLE_MDW_IH = "MilwaukeeDistrictWest_IH";
    private static int[] MDW_IW_Trains = new int[29];
    private static int[] MDW_OW_Trains = new int[29];
    private static int[] MDW_IS_Trains;
    private static int[] MDW_OS_Trains = new int[12];
	private static int[] MDW_IH_Trains;
	private static int[] MDW_OH_Trains;
	//----End MDW------
	//------UPW-------
    private static final String TABLE_UPW_OW = "UnionPacificWest_OW";
	private static final String TABLE_UPW_OS = "UnionPacificWest_OS";
	private static final String TABLE_UPW_OH = "UnionPacificWest_OH";
	private static final String TABLE_UPW_IW = "UnionPacificWest_IW";
	private static final String TABLE_UPW_IS = "UnionPacificWest_IS";
	private static final String TABLE_UPW_IH = "UnionPacificWest_IH";
    private static int[] UPW_IW_Trains = new int[29];
    private static int[] UPW_OW_Trains = new int[29];
    private static int[] UPW_IS_Trains;
    private static int[] UPW_OS_Trains = new int[12];
	private static int[] UPW_IH_Trains;
	private static int[] UPW_OH_Trains;
	//----End UPW------
	//------BNSF-------
    private static final String TABLE_BNSF_OW = "BNSFRailway_OW";
	private static final String TABLE_BNSF_OS = "BNSFRailway_OS";
	private static final String TABLE_BNSF_OH = "BNSFRailway_OH";
	private static final String TABLE_BNSF_IW = "BNSFRailway_IW";
	private static final String TABLE_BNSF_IS = "BNSFRailway_IS";
	private static final String TABLE_BNSF_IH = "BNSFRailway_IH";
    private static int[] BNSF_IW_Trains;
    private static int[] BNSF_OW_Trains;
    private static int[] BNSF_IS_Trains;
    private static int[] BNSF_OS_Trains = new int[12];
	private static int[] BNSF_IH_Trains;
	private static int[] BNSF_OH_Trains;
	//----End BNSF------
	//------HC-------
    private static final String TABLE_HC_OW = "HeritageCorridor_OW";
	private static final String TABLE_HC_IW = "HeritageCorridor_IW";
    private static int[] HC_IW_Trains;
    private static int[] HC_OW_Trains;
	//----End HC------
	//------SWS-------
    private static final String TABLE_SWS_OW = "SouthwestService_OW";
	private static final String TABLE_SWS_OS = "SouthwestService_OS";
	private static final String TABLE_SWS_IW = "SouthwestService_IW";
	private static final String TABLE_SWS_IS = "SouthwestService_IS";
    private static int[] SWS_IW_Trains;
    private static int[] SWS_OW_Trains;
    private static int[] SWS_IS_Trains;
    private static int[] SWS_OS_Trains = new int[12];
	//----End SWS------
	//------RID-------
    private static final String TABLE_RID_OW = "RockIslandDistrict_OW";
	private static final String TABLE_RID_OS = "RockIslandDistrict_OS";
	private static final String TABLE_RID_OH = "RockIslandDistrict_OH";
	private static final String TABLE_RID_IW = "RockIslandDistrict_IW";
	private static final String TABLE_RID_IS = "RockIslandDistrict_IS";
	private static final String TABLE_RID_IH = "RockIslandDistrict_IH";
    private static int[] RID_IW_Trains;
    private static int[] RID_OW_Trains;
    private static int[] RID_IS_Trains;
    private static int[] RID_OS_Trains;
	private static int[] RID_IH_Trains;
	private static int[] RID_OH_Trains;
	//----End RID------
	//------MED-------
    private static final String TABLE_MED_OW = "MetraElectricDistrict_OW";
	private static final String TABLE_MED_OS = "MetraElectricDistrict_OS";
	private static final String TABLE_MED_OH = "MetraElectricDistrict_OH";
	private static final String TABLE_MED_IW = "MetraElectricDistrict_IW";
	private static final String TABLE_MED_IS = "MetraElectricDistrict_IS";
	private static final String TABLE_MED_IH = "MetraElectricDistrict_IH";
    private static int[] MED_IW_Trains;
    private static int[] MED_OW_Trains;
    private static int[] MED_IS_Trains;
    private static int[] MED_OS_Trains;
	private static int[] MED_IH_Trains;
	private static int[] MED_OH_Trains;
	//----End MED------
	//------Metra Station extras-------
    private static final String TABLE_METRA_EXTRAS = "MetraStationExtras";
	private static final String EXTRAS_VENDOR = "vendor";
	private static final String EXTRAS_ATM = "atm";
	
	//----End MED------
    private static final String DATABASE_NAME = "gorails.sqlite";
    private static final String TABLE_CREATE_LINE =
        "CREATE TABLE " + TABLE_LINE + " (" +
        LINE_COLUMN + " TEXT, " +
        COLUMN_SIZE + " INTEGER);";
    private static final String TABLE_CREATE_STATION =
        "CREATE TABLE " + TABLE_STATION + " (" +
        COLUMN_UPN + " TEXT, " +
        COLUMN_MDN + " TEXT, " +
        COLUMN_NCS + " TEXT, " +
        COLUMN_UPNW + " TEXT, " +
        COLUMN_MDW + " TEXT, " +
        COLUMN_UPW + " TEXT, " +
        COLUMN_BNSF + " TEXT, " +
        COLUMN_HC + " TEXT, " +
        COLUMN_SWS + " TEXT, " +
        COLUMN_RID + " TEXT, " +
        COLUMN_MED + " TEXT);";
    private static SQLiteDatabase db;
    DBAdapter(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        db = getWritableDatabase ();
    }

    
    /**
	 * getting Instance of Writable Database
	 * 
	 * @return SQLiteDatabase
	 */
	public  SQLiteDatabase getDB() {
		db = getWritableDatabase ();
		return db;
	}
    @Override
    public void onCreate(SQLiteDatabase db) {
    	
    	if(db.getVersion()==0){
    		createUPNTimes(db);
    		createMDNTimes(db);
    		createNCSTimes(db);
    		createUPNWTimes(db);
    		createMDWTimes(db);
    		createUPWTimes(db);
    		createBNSFTimes(db);
    		createHCTimes(db);
    		createSWSTimes(db);
    		createRIDTimes(db);
    		createMEDTimes(db);
    		createExtras(db);
            db.execSQL(TABLE_CREATE_LINE);
            db.execSQL(TABLE_CREATE_STATION);
    	}
    	
        
    }
public void createExtras(SQLiteDatabase db){

	final String TABLE_CREATE_EXTRAS =
        "CREATE TABLE " + TABLE_METRA_EXTRAS + " (" +
        EXTRAS_VENDOR + " TEXT, " +
        EXTRAS_ATM + " TEXT);";
	
	
    	db.execSQL(TABLE_CREATE_EXTRAS);
    	ContentValues initialValues = new ContentValues();
    	//These are stations that do not have agents
    	String station[] = new String[]{
    			"5414 13th Ave.",
    			"7th St. 1 Block East of Ravine",
    			"2501 S. Eden St.",
    			"1633 Lakeside",
    			"3000 S. Sheridan Rd.",
    			"461 W. Old Elm Rd.",
    			"317 Green Bay Rd.",
    			"510 Roger Williams Ave.",
    			"10 N. St. John's Ave.",
    			"111 N. Green Bay Rd.",
    			"601 Main St.",
    			"7000 N. Ravenswood Ave.",
    			"4800 N. Ravenswood Ave.",
    			"2001 N. Ashland Ave.",
    			//----End of UPN
    			"Ingleside",
    			"Long Lake",
    			"Prarie Crossing",
    			"Lake Forest",
    			"Glen/N. Glenview",
    			"Golf",
    			"Edgebrook",
    			"Forest Glen",
    			"Mayfair",
    			"Grayland",
    			"Healy",
    			"Western Ave.",
    			//---End of MDN
    		    "Antioch",
    		    "Lake Villa",
    		    "Round Lake Beach",
    		    "Washington St. / Grayslake",
    		    "Prairie Crossing / Libertyville",
    		    "Mundelein",
    		    "Vernon Hills",
    		    "Prairie View",
    		    "Buffalo Grove",
    		    "Wheeling",
    		    "Prospect Heights",
    		    "O'Hare Transfer",
    		    "Rosemont",
    		    "Schiller Park",
    		    "Belmont Ave / Franklin Park",
    		    "River Grove",
    		    "Western Avenue",
    		    //------ End of-NCS-----  
    		    "McHenry",
    		    "Woodstock",
    		    "Pingree Road",
    		    "Fox River Grove", 
    		    "Cumberland",
    		    "Dee Road",
    		    "Edison Park",
    		    "Norwood Park",
    		    "Gladstone Park",
    		    "Jefferson Park",
    		    "Irving Park",
    		    "Clybourn",
    		    //-----End UPNW
    		    "Big Timber Road",
    		    "National Street",
    		    "Medinah",
    		    "Wood Dale", 
    		    "Mannheim",
    		    "River Grove",
    		    "Elmwood Park",
    		    "Mont Clare",
    		    "Mars",
    		    "Galewood",
    		    "Hanson Park",
    		    "Grand / Cicero",
    		    "Western Avenue",
    		    //------MD-W
    		    "Elburn",
    		    "La Fox",
    		    "West Chicago",
    		    "Winfield",
    		    "Berkeley",
    		    "Bellwood",
    		    "Melrose Park",
    		    "Maywood",
    		    "River Forest",
    		    "Oak Park",
    		    "Kedzie",
    		    //---------End of UPW
    		    "Fairview Avenue",
    		    "West Hinsdale",
    		    "Highlands",
    		    "Congress Park",
    		    "Hollywood",
    		    "Harlem Ave.",
    		    "LaVergne",
    		    "Cicero",
    		    "Western Avenue",
    		    "Halsted",
    		    //---End BNSF--
    		    "Lockport",
    		    "Lemont",
    		    "Willow Springs",
    		    "Summit",
    		    //End HC
    		    "Manhattan",
    		    "New Lenox Laraway Road",
    		    "Orland Park 179th Street",
    		    "Orland Park 143rd Street",
    		    "Palos Park",
    		    "Palos Heights",
    		    "Worth",
    		    "Chicago Ridge",
    		    "Oak Lawn",
    		    "Ashburn",
    		    "Wrightwood",
    		    "Manhattan",
    		    "New Lenox Laraway Road",
    		    "Orland Park 179th Street",
    		    "Orland Park 143rd Street",
    		    "Palos Park",
    		    "Palos Heights",
    		    "Worth",
    		    "Chicago Ridge",
    		    "Oak Lawn",
    		    "Ashburn",
    		    "Wrightwood",
    		    //end sws
    		    "Hickory Creek",
    		    "Robbins",
    		    "Prairie St.",
    		    "123rd St.",
    		    "119th Street",
    		    "Morgan Park - 115th Street",
    		    "Beverly Hills - 107th Street",
    		    "Brainerd",
    		    "103rd St., Washington Hts",
    		    "95th St. - Longwood",
    		    "Gresham",  
    		    //--Rock Island--
    		    "Blue Island",
    		    "Burr Oak",
    		    "Ashland",
    		    "Racine",
    		    "West Pullman",
    		    "Stewart Ridge",
    		    "State Street",
    		    "93rd St. (South Chicago)",
    		    "87th St. (South Chicago)",
    		    "83rd St. (South Chicago)",
    		    "79th Street (Cheltenham)",
    		    "Windsor Park",
    		    "South Shore",
    		    "Bryn Mawr",
    		    "Stony Island",
    		    "University Park",
    		    "Richton Park",
    		    "Matteson",
    		    "211th Street (Lincoln Highway)",
    		    "Olympia Fields",
    		    "Flossmoor",
    		    "Homewood",
    		    "Calumet",
    		    "Hazel Crest",
    		    "Harvey",
    		    "147th Street (Sibley Boulevard)",
    		    "Ivanhoe",
    		    "Riverdale",
    		    "Kensington / 115th Street",
    		    "111th Street (Pullman)",
    		    "107th Street",
    		    "103rd Street (Rosemoor)",
    		    "95th St., Chicago State Univ.",
    		    "91st Street (Chesterfield)",
    		    "87th Street (Woodruff)",
    		    "83rd Street (Avalon Park)",
    		    "75th Street (Grand Crossing)",
    		    "63rd Street",
    		    "59th St., Univ. of Chicago",
    		    "51st / 53rd Street (Hyde Park)",
    		    "McCormick Place",
    		    "Museum Campus / 11th Street",



    		
    		
    			
    			
    	};
    	for(int i = 0; i < station.length;i++){
    		initialValues.put(EXTRAS_VENDOR, station[i]);
        	db.insertWithOnConflict(TABLE_METRA_EXTRAS, null, initialValues, SQLiteDatabase.CONFLICT_REPLACE);
        	initialValues.clear();
    	}
    	
    	//-----
    	
    	
    	Log.d("Extras", "Extras inserted");
    }
    
public void createMEDTimes(SQLiteDatabase db){
    	
    	//MED has trains that run weekly and saturday 
		MED_IW_Trains = new int[] { 200, 300, 100, 202, 302, 102, 742, 744,
				204, 304, 500, 750, 730, 700, 400, 752, 732, 502, 702, 106,
				754, 734, 402, 704, 504, 756, 604, 736, 408, 706, 758, 738,
				506, 410, 708, 760, 710, 508, 412, 712, 114, 116, 316, 216,
				118, 318, 120, 320, 220, 122, 322, 124, 324, 224, 126, 326,
				128, 328, 228, 130, 330, 232, 332, 132, 334, 236, 336, 136,
				 338, 240, 140, 340, 242, 342, 142, 244, 344, 144, 246,
				346, 146, 248, 348, 148, 250, 350, 150 };

		MED_OW_Trains = new int[] { 103, 303, 203, 305, 105, 107, 205, 309,
				311, 111, 313, 113, 215, 315, 115, 317, 117, 219, 319, 119,
				321, 121, 223, 323, 123, 325, 125, 227, 327, 127, 329, 129,
				331, 131, 231, 401, 701, 501, 731, 751, 403, 703, 601, 733,
				753, 503, 405, 705, 735, 755, 505, 407, 707, 737, 603, 757,
				337, 709, 739, 237, 759, 339, 139, 341, 141, 241, 343, 143,
				243, 145, 345, 245, 147, 347, 247, 149, 349, 249, 151, 351,
				251, 153, 353 };
    	
		MED_IS_Trains = new int[] { 200, 300, 100, 202, 302, 102, 104, 204,
				306, 108, 308, 210, 110, 310, 112, 312, 114, 116, 316, 216,
				118, 318, 120, 320, 220, 122, 322, 124, 324, 224, 126, 326,
				128, 328, 228, 130, 330, 232, 332, 132, 334, 236, 336, 136,
				338, 240, 140, 340, 242, 342, 142, 244, 344, 144, 246, 146,
				248, 348, 148, 250, 350, 150 };
		MED_OS_Trains = new int[] { 103, 303, 203, 305, 105, 207, 309, 111,
				313, 215, 315, 115, 317, 219, 319, 119, 321, 121, 223, 323,
				123, 325, 125, 227, 327, 127, 329, 331, 131, 233, 333, 133,
				335, 135, 235, 137, 239, 339, 139, 341, 141, 241, 343,
				143, 243, 145, 345, 245, 147, 347, 247, 149, 349, 249, 151,
				351, 251, 153, 353 };

    	MED_IH_Trains = new int[]{8302,802,8304,804,8306,806,8308,808,8310,810,8312,812,8314,814,8316,816,8318,818,8320,820};
    	MED_OH_Trains = new int[]{8303,803,8305,805,8307,807,8309,809,8311,811,8313,813,8315,815,8317,817,8319,819,8321,821};
    	String createMED_IW = "CREATE TABLE " + TABLE_MED_IW + " (";
    	for(int i =0;i<MED_IW_Trains.length;i++){
    		if(i==MED_IW_Trains.length-1){
    			createMED_IW+="t"+MED_IW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMED_IW+="t"+MED_IW_Trains[i]+" TEXT, ";
    		}
    	}
    	createMED_IW+=");";
    	db.execSQL(createMED_IW);
    	//---
    	String createMED_OW = "CREATE TABLE " + TABLE_MED_OW + " (";
    	for(int i =0;i<MED_OW_Trains.length;i++){
    		if(i==MED_OW_Trains.length-1){
    			createMED_OW+="t"+MED_OW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMED_OW+="t"+MED_OW_Trains[i]+" TEXT, ";
    		}
    	}
    	createMED_OW+=");";
    	db.execSQL(createMED_OW);
    	//---
    	String createMED_OS = "CREATE TABLE " + TABLE_MED_OS + " (";
    	for(int i =0;i<MED_OS_Trains.length;i++){
    		if(i==MED_OS_Trains.length-1){
    			createMED_OS+="t"+MED_OS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMED_OS+="t"+MED_OS_Trains[i]+" TEXT, ";
    		}
    	}
    	createMED_OS+=");";
    	db.execSQL(createMED_OS);
    	//---
    	String createMED_IS = "CREATE TABLE " + TABLE_MED_IS + " (";
    	for(int i =0;i<MED_IS_Trains.length;i++){
    		if(i==MED_IS_Trains.length-1){
    			createMED_IS+="t"+MED_IS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMED_IS+="t"+MED_IS_Trains[i]+" TEXT, ";
    		}
    	}
    	createMED_IS+=");";
    	db.execSQL(createMED_IS);
    	//---
    	String createMED_IH = "CREATE TABLE " + TABLE_MED_IH + " (";
    	for(int i =0;i<MED_IH_Trains.length;i++){
    		if(i==MED_IH_Trains.length-1){
    			createMED_IH+="t"+MED_IH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMED_IH+="t"+MED_IH_Trains[i]+" TEXT, ";
    		}
    	}
    	createMED_IH+=");";
    	db.execSQL(createMED_IH);
    	//---
    	String createMED_OH = "CREATE TABLE " + TABLE_MED_OH + " (";
    	for(int i =0;i<MED_OH_Trains.length;i++){
    		if(i==MED_OH_Trains.length-1){
    			createMED_OH+="t"+MED_OH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMED_OH+="t"+MED_OH_Trains[i]+" TEXT, ";
    		}
    	}
    	createMED_OH+=");";
    	db.execSQL(createMED_OH);
    	//-----
    	
    	
    	Log.d("MED Tables", "MED Tables Database Insert Complete");
    }
    
    
    
public void createRIDTimes(SQLiteDatabase db){
    	
    	//total index is 32 0-starting
		RID_IW_Trains = new int[] { 600, 400, 402, 602, 404, 604, 406, 606,
				408, 608, 610, 412, 612, 414, 614, 302, 416,
				616, 506, 508, 510, 512, 514, 516, 518, 420, 620, 422, 424,
				622, 526, 528, 530, 532 };

		RID_OW_Trains = new int[] { 401, 403, 503, 505, 507, 509, 511, 513,
				515, 603, 405, 605, 407, 607, 409, 609, 411, 611, 413, 415,
				615, 417, 303, 617, 419, 619, 421, 523, 525, 527, 529, 531, 533 };
    	
    	RID_IS_Trains = new int[]{202,204,210,214,218,222,226,230,234};
    	RID_OS_Trains = new int[]{205,209,213,215,219,221,223,227,231,233};
    	
    	RID_IH_Trains = new int[]{202,206,210,214,218,222,226,230};
    	RID_OH_Trains = new int[]{205,209,213,215,219,223,227,231};
    	String createRID_IW = "CREATE TABLE " + TABLE_RID_IW + " (";
    	for(int i =0;i<RID_IW_Trains.length;i++){
    		if(i==RID_IW_Trains.length-1){
    			createRID_IW+="t"+RID_IW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createRID_IW+="t"+RID_IW_Trains[i]+" TEXT, ";
    		}
    	}
    	createRID_IW+=");";
    	db.execSQL(createRID_IW);
    	//---
    	String createRID_OW = "CREATE TABLE " + TABLE_RID_OW + " (";
    	for(int i =0;i<RID_OW_Trains.length;i++){
    		if(i==RID_OW_Trains.length-1){
    			createRID_OW+="t"+RID_OW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createRID_OW+="t"+RID_OW_Trains[i]+" TEXT, ";
    		}
    	}
    	createRID_OW+=");";
    	db.execSQL(createRID_OW);
    	//---
    	String createRID_OS = "CREATE TABLE " + TABLE_RID_OS + " (";
    	for(int i =0;i<RID_OS_Trains.length;i++){
    		if(i==RID_OS_Trains.length-1){
    			createRID_OS+="t"+RID_OS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createRID_OS+="t"+RID_OS_Trains[i]+" TEXT, ";
    		}
    	}
    	createRID_OS+=");";
    	db.execSQL(createRID_OS);
    	//---
    	String createRID_IS = "CREATE TABLE " + TABLE_RID_IS + " (";
    	for(int i =0;i<RID_IS_Trains.length;i++){
    		if(i==RID_IS_Trains.length-1){
    			createRID_IS+="t"+RID_IS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createRID_IS+="t"+RID_IS_Trains[i]+" TEXT, ";
    		}
    	}
    	createRID_IS+=");";
    	db.execSQL(createRID_IS);
    	//---
    	String createRID_IH = "CREATE TABLE " + TABLE_RID_IH + " (";
    	for(int i =0;i<RID_IH_Trains.length;i++){
    		if(i==RID_IH_Trains.length-1){
    			createRID_IH+="t"+RID_IH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createRID_IH+="t"+RID_IH_Trains[i]+" TEXT, ";
    		}
    	}
    	createRID_IH+=");";
    	db.execSQL(createRID_IH);
    	//---
    	String createRID_OH = "CREATE TABLE " + TABLE_RID_OH + " (";
    	for(int i =0;i<RID_OH_Trains.length;i++){
    		if(i==RID_OH_Trains.length-1){
    			createRID_OH+="t"+RID_OH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createRID_OH+="t"+RID_OH_Trains[i]+" TEXT, ";
    		}
    	}
    	createRID_OH+=");";
    	db.execSQL(createRID_OH);
    	//-----
    	
    	
    	Log.d("RID Tables", "RID Tables Database Insert Complete");
    }
    
    
    
    
public void createSWSTimes(SQLiteDatabase db){
    	
		SWS_IW_Trains = new int[] {802,804,806,808,810,812,818,822,826,830,834,836,838,840,842 };
		SWS_OW_Trains = new int[] {803,805,807,811,815,819,823,825,827,829,831,833,837,839,841};
    	SWS_IS_Trains = new int[]{862,864,866};
    	SWS_OS_Trains = new int[]{861,863,865};
    	String createSWS_IW = "CREATE TABLE " + TABLE_SWS_IW + " (";
    	for(int i =0;i<SWS_IW_Trains.length;i++){
    		if(i==SWS_IW_Trains.length-1){
    			createSWS_IW+="t"+SWS_IW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createSWS_IW+="t"+SWS_IW_Trains[i]+" TEXT, ";
    		}
    	}
    	createSWS_IW+=");";
    	db.execSQL(createSWS_IW);
    	//---
    	String createSWS_OW = "CREATE TABLE " + TABLE_SWS_OW + " (";
    	for(int i =0;i<SWS_OW_Trains.length;i++){
    		if(i==SWS_OW_Trains.length-1){
    			createSWS_OW+="t"+SWS_OW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createSWS_OW+="t"+SWS_OW_Trains[i]+" TEXT, ";
    		}
    	}
    	createSWS_OW+=");";
    	db.execSQL(createSWS_OW);
    	//---
    	String createSWS_OS = "CREATE TABLE " + TABLE_SWS_OS + " (";
    	for(int i =0;i<SWS_OS_Trains.length;i++){
    		if(i==SWS_OS_Trains.length-1){
    			createSWS_OS+="t"+SWS_OS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createSWS_OS+="t"+SWS_OS_Trains[i]+" TEXT, ";
    		}
    	}
    	createSWS_OS+=");";
    	db.execSQL(createSWS_OS);
    	//---
    	String createSWS_IS = "CREATE TABLE " + TABLE_SWS_IS + " (";
    	for(int i =0;i<SWS_IS_Trains.length;i++){
    		if(i==SWS_IS_Trains.length-1){
    			createSWS_IS+="t"+SWS_IS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createSWS_IS+="t"+SWS_IS_Trains[i]+" TEXT, ";
    		}
    	}
    	createSWS_IS+=");";
    	db.execSQL(createSWS_IS);	
    	Log.d("SWS Tables", "SWS Tables Database Insert Complete");
    }
    
public void createHCTimes(SQLiteDatabase db){   	
		HC_IW_Trains = new int[] {914,916,918};
		HC_OW_Trains = new int[] {917,919,921}; 	
    	String createHC_IW = "CREATE TABLE " + TABLE_HC_IW + " (";
    	for(int i =0;i<HC_IW_Trains.length;i++){
    		if(i==HC_IW_Trains.length-1){
    			createHC_IW+="t"+HC_IW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createHC_IW+="t"+HC_IW_Trains[i]+" TEXT, ";
    		}
    	}
    	createHC_IW+=");";
    	db.execSQL(createHC_IW);
    	//---
    	String createHC_OW = "CREATE TABLE " + TABLE_HC_OW + " (";
    	for(int i =0;i<HC_OW_Trains.length;i++){
    		if(i==HC_OW_Trains.length-1){
    			createHC_OW+="t"+HC_OW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createHC_OW+="t"+HC_OW_Trains[i]+" TEXT, ";
    		}
    	}
    	createHC_OW+=");";
    	db.execSQL(createHC_OW); 	
    	Log.d("HC Tables", "HC Tables Database Insert Complete");
    }    


public void createBNSFTimes(SQLiteDatabase db){
    	
    	//total index is 32 0-starting
		BNSF_IW_Trains = new int[] { 1200, 1202, 1204, 1206, 1208, 1210, 1212,
				1214, 1216, 1218, 1220, 1222, 1224, 1226, 1228, 1230, 1232,
				1234, 1236, 1238, 1240, 1242, 1244, 1246, 1248, 1250, 1252,
				1254, 1256, 1258, 1370, 1260, 1262, 1264, 1266, 1268, 1270,
				1272, 1274, 1276, 1280, 1288, 1292, 1294, 1296, 1298, 1324 };

		BNSF_OW_Trains = new int[] { 1201, 1205, 1209, 1211, 1215, 1371, 1221,
				1225, 1227, 1229, 1231, 1233, 1235, 1237, 1239, 1241, 1243,
				1245, 1247, 1249, 1251, 1253, 1255, 1257, 1259, 1261, 1263,
				1265, 1267, 1269, 1271, 1273, 1275, 1277, 1279, 1281, 1283,
				1373, 1285, 1287, 1289, 1291, 1293, 1295, 1297, 1299, 1325 };

    	
    	
    	BNSF_IS_Trains = new int[]{1300,1302,1304,1306,1326,1308,1310,1312,1316,1318,1320,1322,1324};
    	BNSF_OS_Trains = new int[]{1301,1303,1305,1307,1309,1311,1313,1315,1327,1317,1319,1321,1323,1325};
    	
    	BNSF_IH_Trains = new int[]{1302,1306,1310,1314,1316,1318,1320,1322,1324};
    	BNSF_OH_Trains = new int[]{1303,1305,1307,1311,1315,1319,1321,1323,1325};
    	String createBNSF_IW = "CREATE TABLE " + TABLE_BNSF_IW + " (";
    	for(int i =0;i<BNSF_IW_Trains.length;i++){
    		if(i==BNSF_IW_Trains.length-1){
    			createBNSF_IW+="t"+BNSF_IW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createBNSF_IW+="t"+BNSF_IW_Trains[i]+" TEXT, ";
    		}
    	}
    	createBNSF_IW+=");";
    	db.execSQL(createBNSF_IW);
    	//---
    	String createBNSF_OW = "CREATE TABLE " + TABLE_BNSF_OW + " (";
    	for(int i =0;i<BNSF_OW_Trains.length;i++){
    		if(i==BNSF_OW_Trains.length-1){
    			createBNSF_OW+="t"+BNSF_OW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createBNSF_OW+="t"+BNSF_OW_Trains[i]+" TEXT, ";
    		}
    	}
    	createBNSF_OW+=");";
    	db.execSQL(createBNSF_OW);
    	//---
    	String createBNSF_OS = "CREATE TABLE " + TABLE_BNSF_OS + " (";
    	for(int i =0;i<BNSF_OS_Trains.length;i++){
    		if(i==BNSF_OS_Trains.length-1){
    			createBNSF_OS+="t"+BNSF_OS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createBNSF_OS+="t"+BNSF_OS_Trains[i]+" TEXT, ";
    		}
    	}
    	createBNSF_OS+=");";
    	db.execSQL(createBNSF_OS);
    	//---
    	String createBNSF_IS = "CREATE TABLE " + TABLE_BNSF_IS + " (";
    	for(int i =0;i<BNSF_IS_Trains.length;i++){
    		if(i==BNSF_IS_Trains.length-1){
    			createBNSF_IS+="t"+BNSF_IS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createBNSF_IS+="t"+BNSF_IS_Trains[i]+" TEXT, ";
    		}
    	}
    	createBNSF_IS+=");";
    	db.execSQL(createBNSF_IS);
    	//---
    	String createBNSF_IH = "CREATE TABLE " + TABLE_BNSF_IH + " (";
    	for(int i =0;i<BNSF_IH_Trains.length;i++){
    		if(i==BNSF_IH_Trains.length-1){
    			createBNSF_IH+="t"+BNSF_IH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createBNSF_IH+="t"+BNSF_IH_Trains[i]+" TEXT, ";
    		}
    	}
    	createBNSF_IH+=");";
    	db.execSQL(createBNSF_IH);
    	//---
    	String createBNSF_OH = "CREATE TABLE " + TABLE_BNSF_OH + " (";
    	for(int i =0;i<BNSF_OH_Trains.length;i++){
    		if(i==BNSF_OH_Trains.length-1){
    			createBNSF_OH+="t"+BNSF_OH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createBNSF_OH+="t"+BNSF_OH_Trains[i]+" TEXT, ";
    		}
    	}
    	createBNSF_OH+=");";
    	db.execSQL(createBNSF_OH);
    	//-----
    	
    	
    	Log.d("BNSF Tables", "BNSF Tables Database Insert Complete");
    }
    
    
    
    
    public void createUPWTimes(SQLiteDatabase db){
    	
    	//total index is 32 0-starting
    	int currentTrain = 10;
    	for(int i = 0;i<UPW_IW_Trains.length;i++){   		
    		UPW_IW_Trains[i]=currentTrain;
        	currentTrain+=2;
        	//Log.d("UPW_IW_Trains["+i+"]", ""+UPW_IW_Trains[i]);
    		
    	}
    	
    	currentTrain = 11;
    	for(int i = 0;i<UPW_OW_Trains.length;i++){
    		UPW_OW_Trains[i]=currentTrain;
    		currentTrain+=2;
    	}
    	
    	
    	UPW_IS_Trains = new int[]{500,502,504,506,48,508,510,512,66,514};
    	UPW_OS_Trains = new int[]{501,29,503,505,507,509,63,511,71,11};
    	
    	UPW_IH_Trains = new int[]{500,504,506,48,508,510,512,66,514};
    	UPW_OH_Trains = new int[]{501,29,503,505,507,63,511,71,11};
    	String createUPW_IW = "CREATE TABLE " + TABLE_UPW_IW + " (";
    	for(int i =0;i<UPW_IW_Trains.length;i++){
    		if(i==UPW_IW_Trains.length-1){
    			createUPW_IW+="t"+UPW_IW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPW_IW+="t"+UPW_IW_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPW_IW+=");";
    	db.execSQL(createUPW_IW);
    	//---
    	String createUPW_OW = "CREATE TABLE " + TABLE_UPW_OW + " (";
    	for(int i =0;i<UPW_OW_Trains.length;i++){
    		if(i==UPW_OW_Trains.length-1){
    			createUPW_OW+="t"+UPW_OW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPW_OW+="t"+UPW_OW_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPW_OW+=");";
    	db.execSQL(createUPW_OW);
    	//---
    	String createUPW_OS = "CREATE TABLE " + TABLE_UPW_OS + " (";
    	for(int i =0;i<UPW_OS_Trains.length;i++){
    		if(i==UPW_OS_Trains.length-1){
    			createUPW_OS+="t"+UPW_OS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPW_OS+="t"+UPW_OS_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPW_OS+=");";
    	db.execSQL(createUPW_OS);
    	//---
    	String createUPW_IS = "CREATE TABLE " + TABLE_UPW_IS + " (";
    	for(int i =0;i<UPW_IS_Trains.length;i++){
    		if(i==UPW_IS_Trains.length-1){
    			createUPW_IS+="t"+UPW_IS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPW_IS+="t"+UPW_IS_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPW_IS+=");";
    	db.execSQL(createUPW_IS);
    	//---
    	String createUPW_IH = "CREATE TABLE " + TABLE_UPW_IH + " (";
    	for(int i =0;i<UPW_IH_Trains.length;i++){
    		if(i==UPW_IH_Trains.length-1){
    			createUPW_IH+="t"+UPW_IH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPW_IH+="t"+UPW_IH_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPW_IH+=");";
    	db.execSQL(createUPW_IH);
    	//---
    	String createUPW_OH = "CREATE TABLE " + TABLE_UPW_OH + " (";
    	for(int i =0;i<UPW_OH_Trains.length;i++){
    		if(i==UPW_OH_Trains.length-1){
    			createUPW_OH+="t"+UPW_OH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPW_OH+="t"+UPW_OH_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPW_OH+=");";
    	db.execSQL(createUPW_OH);
    	//-----
    	
    	
    	Log.d("UPW Tables", "UPW Tables Database Insert Complete");
    }
    public void createMDWTimes(SQLiteDatabase db){
    	
    	//total index is 32 0-starting
    	int currentTrain = 2200;
    	for(int i = 0;i<MDW_IW_Trains.length;i++){   		
    		MDW_IW_Trains[i]=currentTrain;
        	currentTrain+=2;
        	//Log.d("MDW_IW_Trains["+i+"]", ""+MDW_IW_Trains[i]);
    		
    	}
    	
    	currentTrain = 2201;
    	for(int i = 0;i<MDW_OW_Trains.length;i++){
    		MDW_OW_Trains[i]=currentTrain;
    		currentTrain+=2;
    	}
    	
    	
    	MDW_IS_Trains = new int[]{2700,2702,2706,2708,2710,2714,2716,2718,2720,2722,2724};
    	//MDW_OS_Trains = new int[]{601,703,705,707,709,621,713,715,717,719,721,723};
    	currentTrain = 2701;
    	for(int i = 0;i<MDW_OS_Trains.length;i++){
    		MDW_OS_Trains[i]=currentTrain;
    		currentTrain+=2;
    	}
    	MDW_IH_Trains = new int[]{2700,2704,2708,2714,2716,2718,2720,2722,2724};
    	MDW_OH_Trains = new int[]{2703,2707,2709,2711,2715,2719,2721,2723,2725};
    	String createMDW_IW = "CREATE TABLE " + TABLE_MDW_IW + " (";
    	for(int i =0;i<MDW_IW_Trains.length;i++){
    		if(i==MDW_IW_Trains.length-1){
    			createMDW_IW+="t"+MDW_IW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMDW_IW+="t"+MDW_IW_Trains[i]+" TEXT, ";
    		}
    	}
    	createMDW_IW+=");";
    	db.execSQL(createMDW_IW);
    	//---
    	String createMDW_OW = "CREATE TABLE " + TABLE_MDW_OW + " (";
    	for(int i =0;i<MDW_OW_Trains.length;i++){
    		if(i==MDW_OW_Trains.length-1){
    			createMDW_OW+="t"+MDW_OW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMDW_OW+="t"+MDW_OW_Trains[i]+" TEXT, ";
    		}
    	}
    	createMDW_OW+=");";
    	db.execSQL(createMDW_OW);
    	//---
    	String createMDW_OS = "CREATE TABLE " + TABLE_MDW_OS + " (";
    	for(int i =0;i<MDW_OS_Trains.length;i++){
    		if(i==MDW_OS_Trains.length-1){
    			createMDW_OS+="t"+MDW_OS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMDW_OS+="t"+MDW_OS_Trains[i]+" TEXT, ";
    		}
    	}
    	createMDW_OS+=");";
    	db.execSQL(createMDW_OS);
    	//---
    	String createMDW_IS = "CREATE TABLE " + TABLE_MDW_IS + " (";
    	for(int i =0;i<MDW_IS_Trains.length;i++){
    		if(i==MDW_IS_Trains.length-1){
    			createMDW_IS+="t"+MDW_IS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMDW_IS+="t"+MDW_IS_Trains[i]+" TEXT, ";
    		}
    	}
    	createMDW_IS+=");";
    	db.execSQL(createMDW_IS);
    	//---
    	String createMDW_IH = "CREATE TABLE " + TABLE_MDW_IH + " (";
    	for(int i =0;i<MDW_IH_Trains.length;i++){
    		if(i==MDW_IH_Trains.length-1){
    			createMDW_IH+="t"+MDW_IH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMDW_IH+="t"+MDW_IH_Trains[i]+" TEXT, ";
    		}
    	}
    	createMDW_IH+=");";
    	db.execSQL(createMDW_IH);
    	//---
    	String createMDW_OH = "CREATE TABLE " + TABLE_MDW_OH + " (";
    	for(int i =0;i<MDW_OH_Trains.length;i++){
    		if(i==MDW_OH_Trains.length-1){
    			createMDW_OH+="t"+MDW_OH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMDW_OH+="t"+MDW_OH_Trains[i]+" TEXT, ";
    		}
    	}
    	createMDW_OH+=");";
    	db.execSQL(createMDW_OH);
    	//-----
    	
    	
    	Log.d("MDW Tables", "MDW Tables Database Insert Complete");
    }
    
    
    public void createMDNTimes(SQLiteDatabase db){
    	//29th index is t120
    	//total index is 32 0-starting
    	int currentTrain = 2102;
    	for(int i = 0;i<MDN_IW_Trains.length;i++){
    		if(i!=27){
    			MDN_IW_Trains[i]=currentTrain;
        		currentTrain+=2;
        		//Log.d("MDN_IW_Trains["+i+"]", ""+MDN_IW_Trains[i]);
    		}
    		else{
    			MDN_IW_Trains[i]=120;
    			//Log.d("MDN_IW_Trains["+i+"]", ""+MDN_IW_Trains[i]);
    		}
    	}
    	
    	currentTrain = 2101;
    	for(int i = 0;i<MDN_OW_Trains.length;i++){
    		MDN_OW_Trains[i]=currentTrain;
    		currentTrain+=2;
    	}
    	currentTrain = 2600;
    	for(int i = 0;i<MDN_IS_Trains.length;i++){
    		MDN_IS_Trains[i]=currentTrain;
    		currentTrain+=2;
    	}
    	currentTrain = 2601;
    	for(int i = 0;i<MDN_OS_Trains.length;i++){
    		MDN_OS_Trains[i]=currentTrain;
    		currentTrain+=2;
    	}
    	MDN_IH_Trains = new int[]{2600,2602,2604,2608,2612,2614,2616,2620,2622};
    	MDN_OH_Trains = new int[]{2601,2605,2607,2611,2615,2619,2621,2623,2625,2627};
    	String createMDN_IW = "CREATE TABLE " + TABLE_MDN_IW + " (";
    	for(int i =0;i<MDN_IW_Trains.length;i++){
    		if(i==MDN_IW_Trains.length-1){
    			createMDN_IW+="t"+MDN_IW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMDN_IW+="t"+MDN_IW_Trains[i]+" TEXT, ";
    		}
    	}
    	createMDN_IW+=");";
    	db.execSQL(createMDN_IW);
    	//---
    	String createMDN_OW = "CREATE TABLE " + TABLE_MDN_OW + " (";
    	for(int i =0;i<MDN_OW_Trains.length;i++){
    		if(i==MDN_OW_Trains.length-1){
    			createMDN_OW+="t"+MDN_OW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMDN_OW+="t"+MDN_OW_Trains[i]+" TEXT, ";
    		}
    	}
    	createMDN_OW+=");";
    	db.execSQL(createMDN_OW);
    	//---
    	String createMDN_OS = "CREATE TABLE " + TABLE_MDN_OS + " (";
    	for(int i =0;i<MDN_OS_Trains.length;i++){
    		if(i==MDN_OS_Trains.length-1){
    			createMDN_OS+="t"+MDN_OS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMDN_OS+="t"+MDN_OS_Trains[i]+" TEXT, ";
    		}
    	}
    	createMDN_OS+=");";
    	db.execSQL(createMDN_OS);
    	//---
    	String createMDN_IS = "CREATE TABLE " + TABLE_MDN_IS + " (";
    	for(int i =0;i<MDN_IS_Trains.length;i++){
    		if(i==MDN_IS_Trains.length-1){
    			createMDN_IS+="t"+MDN_IS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMDN_IS+="t"+MDN_IS_Trains[i]+" TEXT, ";
    		}
    	}
    	createMDN_IS+=");";
    	db.execSQL(createMDN_IS);
    	//---
    	String createMDN_IH = "CREATE TABLE " + TABLE_MDN_IH + " (";
    	for(int i =0;i<MDN_IH_Trains.length;i++){
    		if(i==MDN_IH_Trains.length-1){
    			createMDN_IH+="t"+MDN_IH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMDN_IH+="t"+MDN_IH_Trains[i]+" TEXT, ";
    		}
    	}
    	createMDN_IH+=");";
    	db.execSQL(createMDN_IH);
    	//---
    	String createMDN_OH = "CREATE TABLE " + TABLE_MDN_OH + " (";
    	for(int i =0;i<MDN_OH_Trains.length;i++){
    		if(i==MDN_OH_Trains.length-1){
    			createMDN_OH+="t"+MDN_OH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createMDN_OH+="t"+MDN_OH_Trains[i]+" TEXT, ";
    		}
    	}
    	createMDN_OH+=");";
    	db.execSQL(createMDN_OH);
    	//-----
    	
    	
    	Log.d("MDN Tables", "MDN Tables Database Insert Complete");
    }
    
    public void createUPNWTimes(SQLiteDatabase db){
    	//29th index is t120
    	//total index is 32 0-starting
    	int currentTrain = 602;
    	for(int i = 0;i<UPNW_IW_Trains.length;i++){
    		
    		UPNW_IW_Trains[i]=currentTrain;
        	currentTrain+=2;
        	//Log.d("UPNW_IW_Trains["+i+"]", ""+UPNW_IW_Trains[i]);
    		
    	}
    	
    	currentTrain = 601;
    	for(int i = 0;i<UPNW_OW_Trains.length;i++){
    		UPNW_OW_Trains[i]=currentTrain;
    		currentTrain+=2;
    	}
    	
    	
    	UPNW_IS_Trains = new int[]{700,702,706,710,712,714,716,646,720,724,726};
    	UPNW_OS_Trains = new int[]{601,703,705,707,709,621,713,715,717,719,721,723};
    	UPNW_IH_Trains = new int[]{710,714,728,648,654,730,662};
    	UPNW_OH_Trains = new int[]{601,705,617,711,725,719,721,665};
    	String createUPNW_IW = "CREATE TABLE " + TABLE_UPNW_IW + " (";
    	for(int i =0;i<UPNW_IW_Trains.length;i++){
    		if(i==UPNW_IW_Trains.length-1){
    			createUPNW_IW+="t"+UPNW_IW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPNW_IW+="t"+UPNW_IW_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPNW_IW+=");";
    	db.execSQL(createUPNW_IW);
    	//---
    	String createUPNW_OW = "CREATE TABLE " + TABLE_UPNW_OW + " (";
    	for(int i =0;i<UPNW_OW_Trains.length;i++){
    		if(i==UPNW_OW_Trains.length-1){
    			createUPNW_OW+="t"+UPNW_OW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPNW_OW+="t"+UPNW_OW_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPNW_OW+=");";
    	db.execSQL(createUPNW_OW);
    	//---
    	String createUPNW_OS = "CREATE TABLE " + TABLE_UPNW_OS + " (";
    	for(int i =0;i<UPNW_OS_Trains.length;i++){
    		if(i==UPNW_OS_Trains.length-1){
    			createUPNW_OS+="t"+UPNW_OS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPNW_OS+="t"+UPNW_OS_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPNW_OS+=");";
    	db.execSQL(createUPNW_OS);
    	//---
    	String createUPNW_IS = "CREATE TABLE " + TABLE_UPNW_IS + " (";
    	for(int i =0;i<UPNW_IS_Trains.length;i++){
    		if(i==UPNW_IS_Trains.length-1){
    			createUPNW_IS+="t"+UPNW_IS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPNW_IS+="t"+UPNW_IS_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPNW_IS+=");";
    	db.execSQL(createUPNW_IS);
    	//---
    	String createUPNW_IH = "CREATE TABLE " + TABLE_UPNW_IH + " (";
    	for(int i =0;i<UPNW_IH_Trains.length;i++){
    		if(i==UPNW_IH_Trains.length-1){
    			createUPNW_IH+="t"+UPNW_IH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPNW_IH+="t"+UPNW_IH_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPNW_IH+=");";
    	db.execSQL(createUPNW_IH);
    	//---
    	String createUPNW_OH = "CREATE TABLE " + TABLE_UPNW_OH + " (";
    	for(int i =0;i<UPNW_OH_Trains.length;i++){
    		if(i==UPNW_OH_Trains.length-1){
    			createUPNW_OH+="t"+UPNW_OH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPNW_OH+="t"+UPNW_OH_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPNW_OH+=");";
    	db.execSQL(createUPNW_OH);
    	//-----
    	
    	
    	Log.d("UPNW Tables", "UPNW Tables Database Insert Complete");
    }
    
    public void createNCSTimes(SQLiteDatabase db){
    	//29th index is t120
    	//total index is 32 0-starting
    	int currentTrain = 100;
    	for(int i = 0;i<NCS_IW_Trains.length;i++){
    		
    		NCS_IW_Trains[i]=currentTrain;
        	currentTrain+=2;
        	
    	}
    	currentTrain = 101;
    	for(int i = 0;i<NCS_OW_Trains.length;i++){
    		NCS_OW_Trains[i]=currentTrain;
    		currentTrain+=2;
    	}
    	
    	String createNCS_IW = "CREATE TABLE " + TABLE_NCS_IW + " (";
    	for(int i =0;i<NCS_IW_Trains.length;i++){
    		if(i==NCS_IW_Trains.length-1){
    			createNCS_IW+="t"+NCS_IW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createNCS_IW+="t"+NCS_IW_Trains[i]+" TEXT, ";
    		}
    	}
    	createNCS_IW+=");";
    	db.execSQL(createNCS_IW);
    	//---
    	String createNCS_OW = "CREATE TABLE " + TABLE_NCS_OW + " (";
    	for(int i =0;i<NCS_OW_Trains.length;i++){
    		if(i==NCS_OW_Trains.length-1){
    			createNCS_OW+="t"+NCS_OW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createNCS_OW+="t"+NCS_OW_Trains[i]+" TEXT, ";
    		}
    	}
    	createNCS_OW+=");";
    	db.execSQL(createNCS_OW);
    	//---
    	
    	
    	
    	Log.d("NCS Tables", "NCS Tables Database Insert Complete");
    }
    
    
    public void createUPNTimes(SQLiteDatabase db){
    	
    	int currentTrain = 300;
    	for(int i = 0;i<UPN_IW_Trains.length;i++){    		
    		UPN_IW_Trains[i]=currentTrain;
    		//Log.d("UPN Column Name", ""+currentTrain);
    		currentTrain+=2;
    		
    	}
    	
    	currentTrain = 301;
    	for(int i = 0;i<UPN_OW_Trains.length;i++){
    		UPN_OW_Trains[i]=currentTrain;
    		//Log.d("UPN Column*2 Name", ""+currentTrain);
    		currentTrain+=2;
    	}
    	UPN_IS_Trains = new int[]{302,800,802,804,806,334,336,338,342,810,812,814,818};
    	UPN_OS_Trains = UPN_Trains.UPN_OS_Trains;//new int[]{309,319,801,325,329,807,809,811,111,813,361,365,367,301};
    	UPN_IH_Trains = new int[]{802,334,808,338,342,810,812,814,816};
    	UPN_OH_Trains = new int[]{301,321,803,805,807,809,111,815,363,367};
    	String createUPN_IW = "CREATE TABLE " + TABLE_UPN_IW + " (";
    	for(int i =0;i<UPN_IW_Trains.length;i++){
    		if(i==UPN_IW_Trains.length-1){
    			createUPN_IW+="t"+UPN_IW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPN_IW+="t"+UPN_IW_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPN_IW+=");";
    	db.execSQL(createUPN_IW);
    	//---
    	String createUPN_OW = "CREATE TABLE " + TABLE_UPN_OW + " (";
    	for(int i =0;i<UPN_OW_Trains.length;i++){
    		if(i==UPN_OW_Trains.length-1){
    			createUPN_OW+="t"+UPN_OW_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPN_OW+="t"+UPN_OW_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPN_OW+=");";
    	db.execSQL(createUPN_OW);
    	//---
    	String createUPN_OS = "CREATE TABLE " + TABLE_UPN_OS + " (";
    	for(int i =0;i<UPN_OS_Trains.length;i++){
    		if(i==UPN_OS_Trains.length-1){
    			createUPN_OS+="t"+UPN_OS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPN_OS+="t"+UPN_OS_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPN_OS+=");";
    	db.execSQL(createUPN_OS);
    	//---
    	String createUPN_IS = "CREATE TABLE " + TABLE_UPN_IS + " (";
    	for(int i =0;i<UPN_IS_Trains.length;i++){
    		if(i==UPN_IS_Trains.length-1){
    			createUPN_IS+="t"+UPN_IS_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPN_IS+="t"+UPN_IS_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPN_IS+=");";
    	db.execSQL(createUPN_IS);
    	//---
    	String createUPN_IH = "CREATE TABLE " + TABLE_UPN_IH + " (";
    	for(int i =0;i<UPN_IH_Trains.length;i++){
    		if(i==UPN_IH_Trains.length-1){
    			createUPN_IH+="t"+UPN_IH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPN_IH+="t"+UPN_IH_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPN_IH+=");";
    	db.execSQL(createUPN_IH);
    	//---
    	String createUPN_OH = "CREATE TABLE " + TABLE_UPN_OH + " (";
    	for(int i =0;i<UPN_OH_Trains.length;i++){
    		if(i==UPN_OH_Trains.length-1){
    			createUPN_OH+="t"+UPN_OH_Trains[i]+" TEXT";    			
    		}
    		else{
    			createUPN_OH+="t"+UPN_OH_Trains[i]+" TEXT, ";
    		}
    	}
    	createUPN_OH+=");";
    	db.execSQL(createUPN_OH);
    	//-----
    	
    	
    	Log.d("UPN Tables", "UPN Tables Database Insert Complete");
    }
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
	}
}